Skip to content

Conversation

Mashiro2000
Copy link

Description

#881

# file:src/strands/tools/mcp/mcp_types.py
# because it is a TypedDict, we use `_meta` instead of `meta`.
class MCPToolResult(ToolResult):
    _meta: NotRequired[Dict[str, Any]]  # add logic,
    structuredContent: NotRequired[Dict[str, Any]]

# file:src/strands/tools/mcp/mcp_client.py
# method:_handle_tool_result
result = MCPToolResult(
    status=status,
    toolUseId=tool_use_id,
    content=mapped_contents,
    _meta=call_tool_result.meta,  # add logic
)

Related Issues

Issues #881

Documentation PR

Type of Change

Bug fix

Bug fix
New feature
Breaking change
Documentation update
Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Mashiro2000
Copy link
Author

Please merge it. I believe it complies with the MCP specifications, and my business needs to use _meta to carry business parameters, such as token_usage.

status=status,
toolUseId=tool_use_id,
content=mapped_contents,
_meta=call_tool_result.meta,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi a couple small things,

  1. lets be consistent with structuredContent and only provide it if call_tool_result.meta, is not none.
  2. I think I prefer to just have meta instead of _meta
  3. lets add unit tests
  4. Lets add integ tests by modifying our echo_server in the tests_integ/mcp/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants